import logger from '../utils/logger.js';

function requestLoggerMiddleware(req, res, next) {
    try {
        // 记录请求信息
        const logMessage = `[${req.method}] ${req.originalUrl} - IP: ${req.ip}`;
        logger.info(logMessage);
    } catch (error) {
        // 即使日志记录失败，也不影响请求继续处理
        console.error('日志记录失败:', error);
    }
    next();
}

export default requestLoggerMiddleware;